import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AuthGuard } from 'src/app/guard/auth.guard';
import { TabsPage } from './tabs.page';

const routes: Routes = [
  {
    path: 'tabs',
    component: TabsPage,
    children: [
      {
        path: 'reading',
        loadChildren: () =>
          import('../reading/reading.module').then((m) => m.ReadingPageModule),
        canActivate: [AuthGuard],
      },

      {
        path: 'adding',
        loadChildren: () =>
          import('../collection/collection.module').then(
            (m) => m.CollectionPageModule
          ),
        canActivate: [AuthGuard],
      },
      {
        path: 'management',
        loadChildren: () =>
          import('../management/management.module').then(
            (m) => m.ManagementPageModule
          ),
        canActivate: [AuthGuard],
      },
      {
        path: 'management/modification',
        loadChildren: () =>
          import('../modification/modification.module').then(
            (m) => m.ModificationPageModule
          ),
        canActivate: [AuthGuard],
      },
      {
        path: 'profile',
        loadChildren: () =>
          import('../profile/profile.module').then((m) => m.ProfilePageModule),
      },

      {
        path: '',
        redirectTo: '/tabs/reading',
        pathMatch: 'full',
      },
    ],
  },
  {
    path: '',
    redirectTo: '/tabs/reading',
    pathMatch: 'full',
  },
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
})
export class TabsPageRoutingModule {}
